package edu.gatech.volt2.drdoommgt.presenter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import edu.gatech.volt2.drdoommgt.domain.Prescription;
import edu.gatech.volt2.drdoommgt.gui.IPrescriptionView;
import edu.gatech.volt2.drdoommgt.gui.PrescriptionView;

public class PrescriptionPresenter implements ActionListener{

	
	private IPrescriptionView myView;
	private TreatmentRecordPresenter callback;
	/**
	 * 
	 */
	public PrescriptionPresenter() {

	}
	
	public PrescriptionPresenter(TreatmentRecordPresenter treatment_presenter) {
		myView = new PrescriptionView();
		myView.addListener(this);
		myView.showSelf();
		callback = treatment_presenter;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if( e.getSource() == myView.getAddButton() ){
			Prescription p = new Prescription(myView.getDrug(), myView.getDosage(), myView.getInstructions(), myView.getPrice());
			callback.addNewPrescription(p);
			myView.hideSelf();
		}else if ( e.getSource() == myView.getCancelButton() ){
			myView.hideSelf();
		}
	}

	
	
}
